﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using BNSharp;
using BNSharp.BattleNet;
using System.Configuration;

namespace Reticle
{
    public class Settings : IBattleNetSettings
    {
        public Dictionary<string, string> Verbytes { get; private set; }

        public string Client
        {
            get;
            set;
        }

        public string HomeChannel
        {
            get;
            set;
        }

        public int VersionByte
        {
            get
            {
                switch (Client)
                {
                    case "STAR":
                    case "SEXP":
                        return Manager.GetVerbyte(Client);
                    case "W2BN":
                        return Manager.GetVerbyte(Client);
                    case "WAR3":
                    case "W3XP":
                        return Manager.GetVerbyte(Client);
                    case "D2DV":
                    case "D2XP":
                        return Manager.GetVerbyte(Client);
                    default:
                        return Manager.GetVerbyte(Client);
                }
            }
            set
            {

            }
        }

        public string CdKey1
        {
            get;
            set;
        }

        public string CdKey2
        {
            get;
            set;
        }

        //TODO: update the paths maybe?
        public string GameExe
        {
            get
            {
                try
                {
                    switch (Client)
                    {
                        case "STAR":
                        case "SEXP":
                            //return Application.StartupPath + @"\files\hashes\STAR\Starcraft.exe";
                            return Manager.CheckHashes(Client, "GameExe");
                        case "W2BN":
                            //return Application.StartupPath + @"\files\hashes\W2BN\Warcraft II BNE.exe";
                            return Manager.CheckHashes(Client, "GameExe");
                        case "WAR3":
                        case "W3XP":
                            //return Application.StartupPath + @"\files\hashes\WAR3\war3.exe";
                            return Manager.CheckHashes(Client, "GameExe");
                        case "D2DV":
                            //return Application.StartupPath + @"\files\hashes\D2DV\Game.exe";
                            return Manager.CheckHashes(Client, "GameExe");
                        case "D2XP":
                            //return Application.StartupPath + @"\files\hashes\D2XP\Game.exe";
                            return Manager.CheckHashes(Client, "GameExe");
                        default:
                            return "";
                    }
                }
                catch (Exception) { return Application.StartupPath; }
            }
            set
            {

            }
        }

        //TODO: update more paths..
        public string GameFile2
        {
            get
            {
                try
                {
                    switch (Client)
                    {
                        case "STAR":
                        case "SEXP":
                            //return Application.StartupPath + @"\files\hashes\STAR\Storm.dll";
                            return Manager.CheckHashes(Client, "GameFile2");
                        case "W2BN":
                            //return Application.StartupPath + @"\files\hashes\W2BN\Storm.dll";
                            return Manager.CheckHashes(Client, "GameFile2");
                        case "WAR3":
                        case "W3XP":
                            //return Application.StartupPath + @"\files\hashes\WAR3\Storm.dll";
                            return Manager.CheckHashes(Client, "GameFile2");
                        case "D2DV":
                            //return Application.StartupPath + @"\files\hashes\D2DV\Bnclient.dll";
                            return Manager.CheckHashes(Client, "GameFile2");
                        case "D2XP":
                            //return Application.StartupPath + @"\files\hashes\D2XP\Bnclient.dll";
                            return Manager.CheckHashes(Client, "GameFile2");
                        default:
                            return "";
                    }
                }
                catch (Exception) { return Application.StartupPath; }
            }
            set
            {

            }
        }

        //TODO: more paths
        public string GameFile3
        {
            get
            {
                try
                {
                    switch (Client)
                    {
                        case "STAR":
                        case "SEXP":
                            //return Application.StartupPath + @"\files\hashes\STAR\Battle.snp";
                            return Manager.CheckHashes(Client, "GameFile3");
                        case "W2BN":
                            //return Application.StartupPath + @"\files\hashes\W2BN\Battle.snp";
                            return Manager.CheckHashes(Client, "GameFile3");
                        case "WAR3":
                        case "W3XP":
                            //return Application.StartupPath + @"\files\hashes\WAR3\game.dll";
                            return Manager.CheckHashes(Client, "GameFile3");
                        case "D2DV":
                            //return Application.StartupPath + @"\files\hashes\D2DV\D2Client.dll";
                            return Manager.CheckHashes(Client, "GameFile3");
                        case "D2XP":
                            //return Application.StartupPath + @"\files\hashes\D2XP\D2Client.dll";
                            return Manager.CheckHashes(Client, "GameFile3");
                        default:
                            return "";
                    }
                }
                catch (Exception) { return Application.StartupPath; }
            }
            set
            {

            }
        }

        public string Username
        {
            get;
            set;
        }

        //TODO: more paths
        public string ImageFile
        {
            get
            {
                try
                {
                    switch (Client)
                    {
                        case "STAR":
                        case "SEXP":
                            //return Application.StartupPath + @"\files\hashes\STAR\STAR.bin";
                            return Manager.CheckHashes(Client, "ImageFile");
                        case "W2BN":
                            //return Application.StartupPath + @"\files\hashes\W2BN\W2BN.bin";
                            return Manager.CheckHashes(Client, "ImageFile");
                        case "WAR3":
                        case "W3XP":
                            //return Application.StartupPath + @"\files\hashes\WAR3\WAR3.bin";
                            return Manager.CheckHashes(Client, "ImageFile");
                        case "D2DV":
                            //return Application.StartupPath + @"\files\hashes\D2DV\D2DV.bin";
                            return Manager.CheckHashes(Client, "ImageFile");
                        case "D2XP":
                            //return Application.StartupPath + @"\files\hashes\D2XP\D2XP.bin";
                            return Manager.CheckHashes(Client, "ImageFile");
                        default:
                            return "";
                    }
                }
                catch (Exception) { return Application.StartupPath; }
            }
            set
            {

            }
        }

        public string Password
        {
            get;
            set;
        }

        public string Server
        {
            get;
            set;
        }

        public int Port
        {
            get
            {
                return 6112;
            }
            set
            {
            }
        }

        public string CdKeyOwner
        {
            get;
            set;
        }


        public PingType PingMethod
        {
            get
            {
                return PingType.Normal;
            }
            set
            {
            }
        }
    }
}
